<template>
  <div class="comment-item">
    <div class="author">
      <div class="avatar">
        <img :src="comment.author.image" :alt="comment.author.username">
      </div>
      <h4>{{comment.author.username}}</h4>
    </div>
    <div class="body">
      <p>{{comment.body}}</p>
      <div class="footer">{{(new Date(comment.createdAt)).toLocaleString()}}</div>
    </div>
  </div>
</template>

<script lang="ts">
  import { defineComponent, PropType } from 'vue'
  export default defineComponent({
    props: {
      comment: {
        type: Object as PropType<ArticleComment>,
        required: true
      }
    },
    setup (props) {
      console.log(props.comment)
    }
  })
</script>

<style lang="scss" scoped>
  .comment-item {
    display: flex;
    height: 160px;
    width: 70%;
    margin: 0 auto;
    border: 1px solid #E6E6E6;
    margin-bottom: 20px;
    .author {
      width: 120px;
      padding-top: 20px;
      display: flex;
      flex-direction: column;
      align-items: center;
      .avatar {
        width: 80px;
        height: 80px;
      }
      h4 {
        margin-top: 20px;
      }
    }
    .body {
      flex: 1;
      padding: 20px 20px 10px 20px;
      line-height: 1.5;
      text-indent: 2em;
      font-size: 14px;
      display: flex;
      flex-direction: column;
      p {
        flex: 1;
      }
      .footer {
        text-align: right;
      }
    }
  }
</style>